Repository navigation
Clear the default flood scope's old name when a shorter one is set 🤖🤖 - #3899
Open
hamsolodev wants to merge 1 commit into
Open
hamsolodev wants to merge 1 commit into
hamsolodev wants to merge 1 commit into
Conversation
CMD_SET_DEFAULT_FLOOD_SCOPE copied the new name over the old one with strcpy, leaving the bytes after its NUL as they were. A shorter name set over a longer one kept the longer one's tail, and CMD_GET_DEFAULT_FLOOD_SCOPE sends all 31 bytes of the field. Copy with StrHelper::strzcpy, which NUL-pads the rest of the field. Fixes meshcore-dev#3891
This was referenced Nov 22, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CMD_SET_DEFAULT_FLOOD_SCOPEcopies the new name into_prefs.default_scope_namewithstrcpy(examples/companion_radio/MyMesh.cpp:1983on dev, 1993 at companion-v1.18.0), so when the new name is shorter than the old one, the bytes after its NUL keep the old name's tail.CMD_GET_DEFAULT_FLOOD_SCOPEthen sends all 31 bytes of the field (MyMesh.cpp:1999on dev). The firmware itself reads the name only up to the NUL, and the JSON prefs file is written only up to the NUL, so the tail lives in RAM until the next boot; but a client that reads the whole field shows a joined name.The change copies with
StrHelper::strzcpy, which NUL-pads the rest of the field, so nothing of the old name is left. It is one line; the clear branch alreadymemsets the field.Verified on the host build (MeshBench, companion-v1.18.0 with and without the change), with a client I'm writing's raw frames: set
#au-vic-gipps, then#au, then read it back.Before (the name field is the 31 bytes after
1c):After:
The same kind of stale bytes after a NUL, left alone here to keep this to one fix:
CMD_GET_CHANNELcopies the channel name intoout_framewithstrcpyand sends 32 bytes (MyMesh.cpp:1749on dev), so the bytes after the name's NUL are whatever an earlier frame left inout_frame.CMD_SET_CHANNELcopies the name into a stackChannelDetailswithStrHelper::strncpy, which doesn't pad (MyMesh.cpp:1762), andsaveChannelswrites all 32 bytes (DataStore.cpp:358), so uninitialised stack bytes reach the channels file.Fixes #3891
meshcore_py's side of the display (it reads the field to its end, not to the first NUL) is meshcore-dev/meshcore_py#128, part of meshcore-dev/meshcore_py#119.